home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 7081 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.2 KB

  1. Path: dawn.mmm.com!news
  2. From: kjhopps@mmm.com (Kevin J Hopps)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: Will it be auto-deleted?
  5. Date: 21 Feb 1996 18:02:14 GMT
  6. Organization: 3M - St. Paul, MN  55144-1000 US
  7. Message-ID: <4gfmn6$bsl@dawn.mmm.com>
  8. References: <1996Feb20.110314.46035@yogi.urz.unibas.ch>
  9. Reply-To: kjhopps@mmm.com
  10. X-Newsreader: TIN [version 1.2 PL2]
  11.  
  12. Song Jin (song@iso.iso.unibas.ch) wrote:
  13. > I have a question:
  14.  
  15. > void myfunction(void)
  16. > {
  17. >  double *mypointer = new double[100];
  18.  
  19. >  .....
  20.  
  21. > }
  22.  
  23. > The mypointer and the buffer it pointed will be auto-deleted after returned
  24. > from myfunction, am I right?
  25.  
  26. No, as others have said.  If you want an array of double to live for the
  27. duration of myfunction(), and you know the dimension ahead of time, use
  28. automatic storage:
  29.     void myfunction()
  30.     {
  31.     double myarray[100];
  32.     ...
  33.     }
  34. --
  35. Kevin J. Hopps                  e-mail: kjhopps@mmm.com
  36. 3M Company                      phone:  (612) 737-4643
  37. 3M Center, Bldg. 235-2D-57      fax:    (612) 737-2700
  38. St. Paul, MN 55144-1000         Opinions are my own.  I don't speak for 3M.
  39.     But 3M speaks for me -- I did not write the following line:
  40.  
  41. Opinions expressed herein are my own and may not represent those of 3M.
  42.